<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    final String MENU_HOME_TEXT = "首页",
            MENU_AGENCY_TEXT = "代理机构管理", MENU_AGENCY_ADD_TEXT = "新增代理机构", MENU_AGENCY_LIST_TEXT = "代理机构列表",
            MENU_MERCHANT_TEXT = "商户管理", MENU_MERCHANT_ADD_TEXT = "新增商户", MENU_MERCHANT_LIST_TEXT = "商户列表",MENU_MERCHANTTRANSACTION_LIST_TEXT = "订单列表",
            MENU_NEWS_TEXT = "文档/公告管理",MENU_NEWS_ADD_TEXT = "新增文档", MENU_NEWS_LIST_TEXT = "文档信息列表",
            MENU_SYSTEM_TEXT = "系统设置",MENU_SYSTEM_ADMINISTRATOR_ADD_TEXT = "新增用户",MENU_SYSTEM_ADMINISTRATOR_LIST_TEXT = "用户列表",MENU_SYSTEM_EDITPASSWORD_TEXT = "修改密码";

    final String MENU_HOME = "article_home",
            MENU_AGENCY = "menu_agency", MENU_AGENCY_ADD = "menu_agency_add", MENU_AGENCY_LIST = "menu_agency_list",
            MENU_MERCHANT = "menu_merchant", MENU_MERCHANT_ADD = "menu_merchant_add", MENU_MERCHANT_LIST = "menu_merchant_list",MENU_MERCHANTTRANSACTION_LIST = "menu_merchanttransaction_list",
            MENU_NEWS = "menu_news",MENU_NEWS_ADD = "menu_news_add", MENU_NEWS_LIST = "menu_news_list",
            MENU_SYSTEM = "menu_system",MENU_SYSTEM_ADMINISTRATOR_ADD = "menu_system_administrator_add",MENU_SYSTEM_ADMINISTRATOR_LIST = "menu_system_administrator_list",MENU_SYSTEM_EDITPASSWORD = "menu_system_editpassword";

    String currentMenu = MENU_HOME;
    final String CURRENT_MENU_KEY = "currentMenu";
    if (request.getParameter(CURRENT_MENU_KEY) != null) {
        currentMenu = request.getParameter(CURRENT_MENU_KEY);
    }

%>
<%--左侧菜单栏公共画面--%>
<div class="sidebar" id="sidebar">
    <script type="text/javascript">
        try {
            ace.settings.check('sidebar', 'fixed')
        } catch (e) {
        }
    </script>

    <div class="sidebar-shortcuts" id="sidebar-shortcuts">

        <div class="sidebar-shortcuts-mini" id="sidebar-shortcuts-mini">
            <span class="btn btn-success"></span>

            <span class="btn btn-info"></span>

            <span class="btn btn-warning"></span>

            <span class="btn btn-danger"></span>
        </div>
    </div>
    <!-- #sidebar-shortcuts -->

    <ul class="nav nav-list">
        <li <% if (currentMenu.equalsIgnoreCase(MENU_HOME)) { %> class="active" <%} %> >
            <a href="<%=path%>/control/index.jsp?<%=CURRENT_MENU_KEY%>=<%=MENU_HOME%>">
                <i class="icon-dashboard"></i>
                <span class="menu-text"> <%=MENU_HOME_TEXT%> </span>
            </a>
        </li>

        <%--代理管理--%>
        <li id="menu_agency" style="display: none;" <% if (currentMenu.startsWith(MENU_AGENCY)) { %>class="active open" <%} %> >
            <a href="#" class="dropdown-toggle">
                <i class="icon-user"></i>
                <span class="menu-text"> <%=MENU_AGENCY_TEXT%> </span>
                <b class="arrow icon-angle-down"></b>
            </a>

            <ul class="submenu">
                <li id="menu_agency_add" style="display: none;" <% if (currentMenu.equalsIgnoreCase(MENU_AGENCY)) { %> class="active" <%} %> >
                    <a href="<%=path%>/control/agency/agency_edit_info.jsp?<%=CURRENT_MENU_KEY%>=<%=MENU_AGENCY_ADD%>">
                        <i class="icon-double-angle-right"></i>
                        <%=MENU_AGENCY_ADD_TEXT%>
                    </a>
                </li>

                <li id="menu_agency_list" style="display: none;" <% if (currentMenu.equalsIgnoreCase(MENU_AGENCY)) { %>
                    class="active" <%} %> >
                    <a href="<%=path%>/control/agency/agency_list_info.jsp?<%=CURRENT_MENU_KEY%>=<%=MENU_AGENCY_LIST%>">
                        <i class="icon-double-angle-right"></i>
                        <%=MENU_AGENCY_LIST_TEXT%>
                    </a>
                </li>
            </ul>
        </li>

        <%--商户管理--%>
        <li id="menu_merchant" style="display: none;" <% if (currentMenu.startsWith(MENU_MERCHANT)) { %>class="active open" <%} %> >
            <a href="#" class="dropdown-toggle">
                <i class="icon-user"></i>
                <span class="menu-text"> <%=MENU_MERCHANT_TEXT%> </span>
                <b class="arrow icon-angle-down"></b>
            </a>

            <ul class="submenu">
                <li id="menu_merchant_add" style="display: none;" <% if (currentMenu.equalsIgnoreCase(MENU_MERCHANT)) { %> class="active" <%} %> >
                    <a href="<%=path%>/control/merchant/merchant_edit_info.jsp?<%=CURRENT_MENU_KEY%>=<%=MENU_MERCHANT_ADD%>">
                        <i class="icon-double-angle-right"></i>
                        <%=MENU_MERCHANT_ADD_TEXT%>
                    </a>
                </li>

                <li id="menu_merchant_list" style="display: none;" <% if (currentMenu.equalsIgnoreCase(MENU_MERCHANT)) { %>
                    class="active" <%} %> >
                    <a href="<%=path%>/control/merchant/merchant_list_info.jsp?<%=CURRENT_MENU_KEY%>=<%=MENU_MERCHANT_LIST%>">
                        <i class="icon-double-angle-right"></i>
                        <%=MENU_MERCHANT_LIST_TEXT%>
                    </a>
                </li>
                <li id="menu_merchanttransaction_list" style="display: none;" <% if (currentMenu.equalsIgnoreCase(MENU_MERCHANT)) { %>
                    class="active" <%} %> >
                    <a href="<%=path%>/control/merchant/merchanttransaction_list_info.jsp?<%=CURRENT_MENU_KEY%>=<%=MENU_MERCHANTTRANSACTION_LIST%>">
                        <i class="icon-double-angle-right"></i>
                        <%=MENU_MERCHANTTRANSACTION_LIST_TEXT%>
                    </a>
                </li>
            </ul>
        </li>


    <%--文档公告管理--%>
        <li id="menu_news" style="display: none;" <% if (currentMenu.startsWith(MENU_NEWS)) { %>class="active open" <%} %> >
            <a href="#" class="dropdown-toggle">
                <i class="icon-user"></i>
                <span class="menu-text"> <%=MENU_NEWS_TEXT%> </span>
                <b class="arrow icon-angle-down"></b>
            </a>

            <ul class="submenu">
                <li id="menu_news_add" style="display: none;" <% if (currentMenu.equalsIgnoreCase(MENU_NEWS_TEXT)) { %> class="active" <%} %> >
                    <a href="<%=path%>/control/news/news_edit_info.jsp?<%=CURRENT_MENU_KEY%>=<%=MENU_NEWS_ADD%>">
                        <i class="icon-double-angle-right"></i>
                        <%=MENU_NEWS_ADD_TEXT%>
                    </a>
                </li>

                <li id="menu_news_list" style="display: none;" <% if (currentMenu.equalsIgnoreCase(MENU_NEWS_LIST)) { %>
                    class="active" <%} %> >
                    <a href="<%=path%>/control/news/news_list_info.jsp?<%=CURRENT_MENU_KEY%>=<%=MENU_NEWS_LIST%>">
                        <i class="icon-double-angle-right"></i>
                        <%=MENU_NEWS_LIST_TEXT%>
                    </a>
                </li>
            </ul>
        </li>

        <li id="menu_system" style="display: none;" <% if (currentMenu.startsWith(MENU_SYSTEM)) { %>class="active open" <%} %> >
            <a href="#" class="dropdown-toggle">
                <i class="icon-user"></i>
                <span class="menu-text"> <%=MENU_SYSTEM_TEXT%> </span>
                <b class="arrow icon-angle-down"></b>
            </a>

            <ul class="submenu">
                <li id="menu_system_administrator_add" style="display: none;" <% if (currentMenu.equalsIgnoreCase(MENU_SYSTEM)) { %> class="active" <%} %> >
                    <a href="<%=path%>/control/uc/user_add_info.jsp?<%=CURRENT_MENU_KEY%>=<%=MENU_SYSTEM_ADMINISTRATOR_ADD%>">
                        <i class="icon-double-angle-right"></i>
                           <%=MENU_SYSTEM_ADMINISTRATOR_ADD_TEXT%>
                    </a>
                </li>

                <li id="menu_system_administrator_list" style="display: none;" <% if (currentMenu.equalsIgnoreCase(MENU_SYSTEM)) { %> class="active" <%} %> >
                    <a href="<%=path%>/control/uc/user_info_list.jsp?<%=CURRENT_MENU_KEY%>=<%=MENU_SYSTEM_ADMINISTRATOR_LIST%>">
                        <i class="icon-double-angle-right"></i>
                           <%=MENU_SYSTEM_ADMINISTRATOR_LIST_TEXT%>
                    </a>
                </li>

                <li id="menu_system_editpassword" style="display: none;" <% if (currentMenu.equalsIgnoreCase(MENU_SYSTEM)) { %> class="active" <%} %> >
                    <a href="<%=path%>/control/uc/user_edit_password.jsp?<%=CURRENT_MENU_KEY%>=<%=MENU_SYSTEM_EDITPASSWORD%>">
                        <i class="icon-double-angle-right"></i>
                           <%=MENU_SYSTEM_EDITPASSWORD_TEXT%>
                    </a>
                </li>

            </ul>
        </li>

    </ul>
    <!-- /.nav-list -->

    <div class="sidebar-collapse" id="sidebar-collapse">
        <i class="icon-double-angle-left" data-icon1="icon-double-angle-left" data-icon2="icon-double-angle-right"></i>
    </div>

    <script type="text/javascript">
        try {
            ace.settings.check('sidebar', 'collapsed')
        } catch (e) {
        }
    </script>
</div>
<%--下面这个div是与父页面对接时使用--%>
<div class="main-content">

    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="<%=path%>/control/index.jsp?<%=CURRENT_MENU_KEY%>=<%=MENU_HOME%>">首页</a>
            </li>

            <%--代理机构管理--%>
            <% if (currentMenu.equalsIgnoreCase(MENU_AGENCY_ADD)) { %>
            <li><%=MENU_AGENCY_TEXT%>
            </li>
            <li class="active"><%=MENU_AGENCY_ADD_TEXT%>
            </li>
            <%} %>

            <% if (currentMenu.equalsIgnoreCase(MENU_AGENCY_LIST)) { %>
            <li><%=MENU_AGENCY_TEXT%>
            </li>
            <li class="active"><%=MENU_AGENCY_LIST_TEXT%>
            </li>
            <%} %>

            <%--商户管理--%>
            <% if (currentMenu.equalsIgnoreCase(MENU_MERCHANT_ADD)) { %>
            <li><%=MENU_MERCHANT_TEXT%>
            </li>
            <li class="active"><%=MENU_MERCHANT_ADD_TEXT%>
            </li>
            <%} %>

            <% if (currentMenu.equalsIgnoreCase(MENU_MERCHANT_LIST)) { %>
            <li><%=MENU_MERCHANT_TEXT%>
            </li>
            <li class="active"><%=MENU_MERCHANT_LIST_TEXT%>
            </li>
            <%} %>
            <% if (currentMenu.equalsIgnoreCase(MENU_MERCHANTTRANSACTION_LIST)) { %>
            <li><%=MENU_MERCHANTTRANSACTION_LIST_TEXT%>
            </li>
            <li class="active"><%=MENU_MERCHANTTRANSACTION_LIST_TEXT%>
            </li>
            <%} %>

            <%--文档公告管理--%>
            <% if (currentMenu.equalsIgnoreCase(MENU_NEWS_ADD)) { %>
            <li><%=MENU_NEWS_TEXT%>
            </li>
            <li class="active"><%=MENU_NEWS_ADD_TEXT%>
            </li>
            <%} %>

            <% if (currentMenu.equalsIgnoreCase(MENU_NEWS_LIST)) { %>
            <li><%=MENU_NEWS_TEXT%>
            </li>
            <li class="active"><%=MENU_NEWS_LIST_TEXT%>
            </li>
            <%} %>

            <%--系统设置--%>
            <% if (currentMenu.equalsIgnoreCase(MENU_SYSTEM_ADMINISTRATOR_ADD)) { %>
            <li><%=MENU_SYSTEM_TEXT%>
            </li>
            <li class="active"><%=MENU_SYSTEM_ADMINISTRATOR_ADD_TEXT%>
            </li>
            <%} %>

            <% if (currentMenu.equalsIgnoreCase(MENU_SYSTEM_ADMINISTRATOR_LIST)) { %>
            <li><%=MENU_SYSTEM_TEXT%>
            </li>
            <li class="active"><%=MENU_SYSTEM_ADMINISTRATOR_LIST_TEXT%>
            </li>
            <%} %>

            <% if (currentMenu.equalsIgnoreCase(MENU_SYSTEM_EDITPASSWORD)) { %>
            <li><%=MENU_SYSTEM_TEXT%>
            </li>
            <li class="active"><%=MENU_SYSTEM_EDITPASSWORD_TEXT%>
            </li>
            <%} %>

        </ul>
        <!-- .breadcrumb -->


    </div>

    <%--下面这个div是与父页面对接时使用--%>
    <div class="page-content">
        <div class="page-header">
            <h1>
                <% if (currentMenu.equalsIgnoreCase(MENU_HOME)) { %>
                <%=MENU_HOME_TEXT%>
                <%} %>

                <!--代理机构-->
                <% if (currentMenu.equalsIgnoreCase(MENU_AGENCY_LIST)) { %>
                <%=MENU_AGENCY_LIST_TEXT%>
                <%} %>

                <% if (currentMenu.equalsIgnoreCase(MENU_AGENCY_ADD)) { %>
                <%=MENU_AGENCY_ADD_TEXT%>
                <%} %>

                <!--商户-->
                <% if (currentMenu.equalsIgnoreCase(MENU_MERCHANT_LIST)) { %>
                <%=MENU_MERCHANT_LIST_TEXT%>
                <%} %>

                <% if (currentMenu.equalsIgnoreCase(MENU_MERCHANT_ADD)) { %>
                <%=MENU_MERCHANT_ADD_TEXT%>
                <%} %>

                <% if (currentMenu.equalsIgnoreCase(MENU_MERCHANTTRANSACTION_LIST)) { %>
                <%=MENU_MERCHANTTRANSACTION_LIST_TEXT%>
                <%} %>
                <!--新闻公告-->
                <% if (currentMenu.equalsIgnoreCase(MENU_NEWS_LIST)) { %>
                <%=MENU_NEWS_LIST_TEXT%>
                <%} %>

                <% if (currentMenu.equalsIgnoreCase(MENU_NEWS_ADD)) { %>
                <%=MENU_NEWS_ADD_TEXT%>
                <%} %>

                <!--系统管理-->
                <% if (currentMenu.equalsIgnoreCase(MENU_SYSTEM_ADMINISTRATOR_LIST)) { %>
                <%=MENU_SYSTEM_ADMINISTRATOR_LIST_TEXT%>
                <%} %>

                <% if (currentMenu.equalsIgnoreCase(MENU_SYSTEM_ADMINISTRATOR_ADD)) { %>
                <%=MENU_SYSTEM_ADMINISTRATOR_ADD_TEXT%>
                <%} %>

                <% if (currentMenu.equalsIgnoreCase(MENU_SYSTEM_EDITPASSWORD)) { %>
                <%=MENU_SYSTEM_EDITPASSWORD_TEXT%>
                <%} %>

            </h1>
          </div>
        <!-- /.page-header -->
        <%--最后的一个编译器异常提示不需要处理，因为该页面属于部分页面，有部分标签需要和引入该页面的父页面做对接，所以暂不需要结束--%>

        <%--权限管理--%>
        <script type="text/javascript">
            $(document).ready(function () {
                var userInfo = cochoApp.getUserInfoByStorage();
                if (cochoApp.isNotEmpty(userInfo)) {
                    var roles = userInfo.roles;
                    if (roles == "ROOT") {
                        $("#menu_agency").css('display','block');
                        $("#menu_agency_add").css('display','block');
                        $("#menu_agency_list").css('display','block');

                        $("#menu_merchant").css('display','block');
                        $("#menu_merchant_add").css('display','block');
                        $("#menu_merchant_list").css('display','block');
                        $("#menu_merchanttransaction_list").css('display','block');

                        $("#menu_news").css('display','block');
                        $("#menu_news_add").css('display','block');
                        $("#menu_news_list").css('display','block');

                        $("#menu_system").css('display','block');
                        $("#menu_system_administrator_add").css('display','block');
                        $("#menu_system_administrator_list").css('display','block');
                        $("#menu_system_editpassword").css('display','block');

                    } else if (roles == "ADMIN") {
                        $("#menu_merchant").css('display','block');
                        $("#menu_merchanttransaction_list").css('display','block');

                        $("#menu_system").css('display','block');
                        $("#menu_system_editpassword").css('display','block');
                    }
                } else {
                    cochoAlert.notificationsWarn("用户缓存信息不存在，请重新登录！");
                }
            });
        </script>
